//package com.daixiaowei.controller;
//
//import com.daixiaowei.model.Restaurant;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import java.util.List;
//
//@RestController
//public class RestaurantController {
//
//    @GetMapping("/restaurants")
//    public List<Restaurant> getRestaurants() {
//        return List.of(
//                new Restaurant("惊喜餐厅", "市中心", "特色美食")
//        );
//    }
//}
package com.daixiaowei.controller;

import com.daixiaowei.model.Restaurant;
import com.daixiaowei.service.RestaurantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class RestaurantController {
    @Autowired
    private RestaurantService restaurantService;

    @GetMapping("/restaurants")
    public List<Restaurant> getRestaurants() {
        return restaurantService.getAllRestaurants();
    }

//    @GetMapping("/restaurants")
//    public List<Restaurant> getRestaurants() {
//        return List.of(
//                new Restaurant("惊喜餐厅", "市中心", "特色美食")
//        );
//    }
    @PostMapping("/restaurants/add")
    public Restaurant addRestaurant(@RequestBody Restaurant restaurant) {
        return restaurant;
    }
    // 使用@RequestParam获取查询参数
    @GetMapping("/restaurant/search")
    public Restaurant searchRestaurant(@RequestParam String name) {
        return new Restaurant(name, "未知位置", "未知特色");
    }
}
